package com.yanq.liancar.adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yanq.liancar.R;
import com.yanq.liancar.bean.MyCar;
import com.yanq.liancar.viewholder.ItemMyCarViewHolder;

import java.util.List;

/**
 * Created by wyq on 2018/5/29.
 */

public class MyCarAdapter extends BaseQuickAdapter<MyCar.DataBean, BaseViewHolder> {


    public MyCarAdapter(int layoutResId, @Nullable List<MyCar.DataBean> data) {
        super(layoutResId, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, MyCar.DataBean item) {

        helper.setText(R.id.tv_start, item.getCarBrand().substring(0, 1))
                .setText(R.id.car_num, item.getDriNum())
                .setText(R.id.car_info, item.getCarCate() + "  " + item.getCarType())
                .addOnClickListener(R.id.checkbox);
        TextView textView = helper.getView(R.id.checkbox);
        if (item.getDefaultCar() == 1) {
            textView.setSelected(true);
            textView.setText("默认");
            textView.setTextColor(Color.parseColor("#2987e9"));
        } else {
            textView.setText("设为默认");
            textView.setSelected(false);
            textView.setTextColor(Color.parseColor("#ff454344"));
        }
    }
}
